@extends('admin.common.base-master')

@section('html-head')
    <link href="{{url('css/admin/pagenum.css')}}" rel="stylesheet" />
    @endsection

    @section('html-body')
            <!-- content start -->
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="">套餐列表</a>
        </div>
        <!-- cur-position end -->

        <!-- filter-box start -->
        <div class="filter-box clearfix">
            <div class="fr">
                <a class="addBtn" href="{{route('Admin.Index.packagesAdd')}}">新增</a>
            </div>
        </div>
        <!-- filter-box end -->

        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>套餐名</th>
                    <th>主治科目</th>
                    <th>套餐简介</th>
                    <th>套餐费(单位:元)</th>
                    <th>预约费(单位:元)</th>
                    <th>当前状态</th>
                    <th>是否私人定制</th>
                    <th>是否上架</th>
                </tr>
                </thead>
                <tbody>
                @if($packages && count($packages)>0)
                    @foreach($packages as $package)
                        <tr>
                            <td class="account-td imptc">
                                <span class="photo">
                                    <img src="{{route('Api.Image.Show',['id'=>$package->pak_img])}}" alt="">
                                 </span>
                                <div class="info-box">
                                    <p>
                                        <span class="name">{{$package->doc_name}}</span>
                                    </p>
                                </div>
                            </td>
                            <td>{{$package->pak_subject}}</td>
                            <td>{{$package->pak_detail}}</td>
                            <td>{{$package->consulting_fee}}</td>
                            <td>{{$package->bespeak_fee}}</td>
                            <td>@if($package->is_off == '0')<span class="color3">正常</span>@elseif((int)$package->is_off == '1')<span class="color4">关闭</span> @endif</td>
                            <td><a class="color1" href="{{route('Admin.Index.packagesAdd')}}?id={{$package->id}}">修改套餐</a> | <a class="color5 pak_delete" href="javascript:void(0)" value="{{$package->id}}">删除</a></td>
                            <td><a href="javascript:void(0);"  class="color1 shangjia" value="{{$package->id}}" >@if($package->is_off == '0')下架 @else 上架 @endif</a>
                        </tr>
                    @endforeach
                @endif
                </tbody>
                <tfoot class="order-gl">
                </tfoot>
            </table>
        </div>
        <div>
            {!! $packages->render() !!}
        </div>
        <script>
            var shangjiaUrl = "{{url('/api/shang-jia')}}";
            var deleteUrl = "{{url('/api/delete-package')}}";
            $('.shangjia').click(function () {
                $.get(shangjiaUrl + '/' + $(this).attr('value'),function (data, res) {
                    console.log(data.data);
                    location.reload(true);
                })
            });
            $('.pak_delete').click(function () {
                var  r = confirm("是否删除该套餐");
                if (r == true){
                    $.get(deleteUrl + '/' + $(this).attr('value'),function (data, res) {
                        console.log(data.data);
                        location.reload(true);
                    })
                }else {

                }
            });
        </script>
    </div>
    <!-- content end -->
@endsection